home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Textension / Include / Array.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  2.4 KB  |  103 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Array.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Essam Zaky
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>      1/5/94    EZ        clean up
  13.          <3>      1/5/94    EZ        remove CLongArray to LinkedFrames.cp
  14.          <2>      1/4/94    EZ        clean up
  15.          <1>      1/4/94    EZ        first checked in
  16.  
  17. */
  18.  
  19. #ifndef _Array_
  20. #define _Array_
  21.  
  22. #ifndef _ToolBoxDump_
  23. #include "ToolBoxDump.h"
  24. #endif
  25.  
  26. #ifndef _TextensionCommon_
  27. #include "TextensionCommon.h"
  28. #endif
  29. //***************************************************************************************************
  30.  
  31. #ifdef txtnDebug
  32. extern short gCountArrays;
  33. #endif
  34.  
  35. class    CArray    :    public HandleObject {
  36.     public:
  37.         CArray();
  38.         
  39.         void IArray(short arrayElementSize, short moreElementsCount = 0);
  40.          
  41.         virtual void Free();
  42.         
  43.         void* LockArray(Boolean moveHi = false);
  44.         void    UnlockArray();
  45.         
  46.         void*    GetElementPtr(long elementIndex) const;
  47.         void* GetLastElementPtr() const;
  48.         
  49.         void SetElementsVal(long elementIndex, const void* newElementsPtr, long countElements = 1);
  50.         void GetElementsVal(long elementIndex, void* elementsPtr, long countElements = 1);
  51.         
  52.         void* InsertElements(long countToInsert, const void* newElementsVal, long insertIndex=-1);
  53.         //-1 means at the end. newElementsVal may be nil
  54.         
  55.         virtual long RemoveElements(long removeIndex, long countToRemove);
  56.         //returns the new elements count
  57.         
  58.         OSErr ReplaceElements(long oldCount, long newCount, long replaceIndex, const void* newElements);
  59.         //newElements may be nil
  60.         
  61.         inline long CountElements() const {return fElementsCount;}
  62.         
  63.         OSErr SetElementsCount(long newCount, Boolean compact =false);
  64.         void Compact();
  65.     
  66.         OSErr Reserve(long extraCount);
  67.         
  68.         inline short GetElementSize() {return fElementSize;}
  69.         
  70.     protected:
  71.         long fElementsCount;
  72.         short fElementSize;
  73.  
  74.     private:
  75.         #ifdef __STDC__
  76.         Handle fHandle;
  77.         #else
  78.         long fOffset;
  79.         #endif
  80.         
  81.         short fLockLevel;
  82.         short fMoreElementsCount;
  83.         long fActualElementsCount;
  84.  
  85.         OSErr    SetArraySize(long newElementsCount);
  86. };
  87. //***************************************************************************************************
  88.  
  89. class    CLongTagArray    :    public    CArray {
  90. //Array of elements starting with a long
  91.     public:
  92.         CLongTagArray();
  93.         
  94.         long Search(long val, long* foundVal) const;
  95.  
  96.         long SearchBigger(long val) const;
  97.         
  98.     private:
  99. };
  100. //***************************************************************************************************
  101.  
  102. #endif
  103.